<?php

session_start();
include('system/db/conn.php');
$caiid=$_GET['caiid'];
$parentid=$_GET['parentid'];
$xingxing=$_GET['xingxing'];

$jiajian=0;
if($xingxing==1){
	$jiajian=-2;
}elseif ($xingxing==2) {
	$jiajian=-1;
}elseif ($xingxing==3) {
	$jiajian=0;
}
elseif ($xingxing==4) {
	$jiajian=2;
}
elseif ($xingxing==5) {
	$jiajian=3;
}
$check_query = mysql_query("select * from do_supplier_location_menu where id=".$caiid);
if($result = mysql_fetch_array($check_query)){
	$jiajianl=0;
	$sql="";
	if(!($result['collect_nums']>=0)){
		$jiajianl=0;
	}else{
		$jiajian1=$result['collect_nums'];
	}
if(!(($jiajian1+$jiajian)>0)){
$sql = "update do_supplier_location_menu set collect_nums=0 where id=".$caiid;
}else{
	$zongjia=$jiajian1+$jiajian;
$sql = "update do_supplier_location_menu set collect_nums=$zongjia where id=".$caiid;
}



if(mysql_query($sql,$conn)){
	$newfood="";
$check_query2 = mysql_query("select * from do_deal_order where id=".$parentid);
if($result2 = mysql_fetch_array($check_query2)){
	
		$arrayzhengti = split(" ",$result2['food']);
              		
					
				$count_array = count($arrayzhengti);
					$shuliang=0;
				$x=0;
				for($x==0;$x<$count_array;$x++){
					
				$arrayFensan=split(",",$arrayzhengti[$x]);	
				if($x==($count_array-1)){

				if(!($arrayFensan[0]==$caiid)){

					$newfood.=$arrayzhengti[$x];
					
				}else{

					$newfood.=$arrayFensan[0].",".$arrayFensan[1].",".$xingxing;
				}
			}else{

				if(!($arrayFensan[0]==$caiid)){

					$newfood.=$arrayzhengti[$x]." ";
					
				}else{

					$newfood.=$arrayFensan[0].",".$arrayFensan[1].",".$xingxing." ";
				}

			}
				



			}

			$sql3 = "update do_deal_order set food='$newfood' where id=".$parentid;

		if(mysql_query($sql3,$conn)){

			print_r("yes");

		}

			}




	
}

}


?>